package com.cskaoyan.javase.controlflow.selective3.ifs.exercise4;

/**
 * @description: if练习
 * @author: wuguidong@cskaoyan.onaliyun.com
 **/

import java.util.Scanner;

/**
 * - x>=3时，y = 2x + 1;
 * - -1<=x<3时， y = 2x;
 * - x<=-1时， y = 2x – 1;
 *
 *
 */
public class Demo {
    public static void main(String[] args) {
        //键盘录入一个x，求y的值
        System.out.println("请输入一个int数据：");
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = -1;
        if (x >= 3) {
            y = 2 * x + 1;
        } else if (x >= -1 && x < 3) {
            y = 2 * x;
        } /*else if (x < -1) { //Condition 'x < -1' is always 'true'
            y = 2 * x - 1;
        }*/
        else {
            y = 2 * x - 1;
        }
        System.out.println(y);
    }
}
